﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MadLibrary.Managing.Products
{
    /// <summary>
    /// Holds and manages prodúct category.
    /// </summary>
    public class ProductCategory
    {
        /// <summary>
        /// Gets or sets the name of current product category.
        /// </summary>
        /// <value>
        /// The name of current product category.
        /// </value>
        public string Name { get; set; }
        /// <summary>
        /// Gets or sets the description of current product category.
        /// </summary>
        /// <value>
        /// The description of current product category.
        /// </value>
        public string Description { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="ProductCategory"/> class.
        /// </summary>
        public ProductCategory()
        {
            this.Name = "Unknown category name.";
            this.Description = "Description hasn't been written.";
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ProductCategory"/> class.
        /// </summary>
        /// <param name="Name">The name for new product category.</param>
        public ProductCategory(string Name)
        {
            this.Name = Name;
            this.Description = "Description hasn't been written.";
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ProductCategory"/> class.
        /// </summary>
        /// <param name="Name">The name for new product category.</param>
        /// <param name="Description">The description for new product category.</param>
        public ProductCategory(string Name, string Description)
        {
            this.Name = Name;
            this.Description = Description;
        }

        /// <summary>
        /// Gets the average cost of specified products.
        /// </summary>
        /// <param name="Products">Specifies product collection for average cost calculation.</param>
        /// <returns>Average cost of specified products.</returns>
        public static double GetAverageCost(Products Products)
        {
            double acost = 0.0;
            foreach (Product p in Products)
                acost += p.Cost;
            return acost / Products.Count;
        }
    }
}
